<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    我的第一个electron 项目

    <button id="btn">关闭</button>

    <div id="html" style="width: 100%;height: 300px;background-color: #000;color: #fff;">aaa</div>
    <script>

         const { ipcRenderer } = require('electron');

        document.getElementById('btn').addEventListener('click',()=>{

            console.log('关闭');
            
            //关闭应用程序

          //  ipcRenderer.send("close-window",'请关闭窗口');//渲染进程给主进程发送消息
           var huili=   ipcRenderer.sendSync("close-window",'请关闭窗口');

           console.log("收到的回礼",huili);
            

        })

        ipcRenderer.on("huili",(e,data)=>{

            console.log("接收到的回礼",data);

        })

        ipcRenderer.on("message",(e,data)=>{

            console.log("接收到的消息",data);
        })

        ipcRenderer.on("file-opened",(e,data)=>{
            
            console.log("file-opened",data);

            document.getElementById("html").innerHTML = data;
        })
    </script>
</body>
</html>